package com.miao.common.utils;

import com.github.mustachejava.Code;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author MiaoWenqing
 * @description: 手机验证码操作
 *  @date 2021/2/4 11:06
 */
@Component
public class TelCodeUtil {

    @Resource(name = "myRedisTemplate")
    private RedisTemplate<String,Object> redisTemplate;

    /**
     * 校验验证码
     * @param tel 手机号
     * @param code 验证码
     * @return  0 验证码 不存在 1 验证成功
     */
    public boolean checkTelCode(String tel, String code){
        String s = (String) this.redisTemplate.opsForValue().get("code:" + tel);
        return code.equals(s);
    }






}
